﻿using TbShop.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TbShop.Business.Components
{
    public class RoleAuthorityBC : ServiceComponents<RoleAuthority>, IBusinessContractBase<RoleAuthority>
    {
        public RoleAuthority GetAuthorityByRoleAuth(string roleId, int authId)
        {
            return this.GetAll().Where(r => r.RoleId == roleId && r.AuthorityId == authId).SingleOrDefault();
        }

        public int[] GetAuthoritysByRoleId(string roleId)
        {
            var authorityDatas = this.GetAll().Where(r => r.RoleId == roleId);
            var outcome = authorityDatas.Select(x => x.AuthorityId).ToArray();
            return outcome;
        }
    }
}
